package pers.qianyu.exception;

/**
 * 异常编码枚举
 *
 * @author mizzle rain
 * @date 2020-10-13 13:40
 */
public enum ErrorCodeEnum implements IErrorCodeEnum{
    /**
     * 0 操作成功
     */
    SUCCESS(0, "操作成功"),
    /**
     * 1*** 参数错误
     */
    PARAM_ERROR(1001, "参数错误"),
    PARAM_NULL(1002, "参数为空"),
    PARAM_FORMAT_ERROR(1003, "参数格式错误"),
    PARAM_VALUE_ERROR(1004, "参数数值错误"),
    /**
     * 2*** 系统错误
     */
    SYSTEM_ERROR(2001, "服务异常"),
    UNKNOWN_ERROR(2002, "未知异常"),
    /**
     * 3*** 业务异常
     * 指自定义的异常
     */
    XXX(3001, "业务异常"),
    INSERT_FAILURE(3002, "新增失败"),
    UPDATE_FAILURE(3003, "更新失败"),
    DELETE_FAILURE(3005, "删除失败"),
    RATE_LIMIT_ERROR(3006, "接口被限流了，请稍后再试"),
    FILE_UPLOAD_FAILURE(3007, "文件上传失败"),
    ;
    /**
     * 错误编码
     */
    private Integer code;
    /**
     * 错误描述
     */
    private String message;

    ErrorCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
